﻿// JScript File
function select_change(form) {

    var frm = form;
    var n=0; // total checkbox 
    var m=0; // checkbox checked
    var all; // checkbox check all
    
    for(i=0;i<frm.length;i++){
        if(frm.elements[i].type=='checkbox'){ 
	        n++; 
        }
    }
 
    for(i=0;i<frm.length;i++)
    {
        if(frm.elements[i].type=='checkbox')
        { 
	        if(frm.elements[i].name.indexOf('checkall')!= -1)
	        {	
		        all = frm.elements[i];
	        } 
	        else 
	        if(frm.elements[i].checked==true)
	        { 
		        m++	;
	        }
        }
    }
    
    if(n-1==m)
    {
	    all.checked = true;
    }
    else {
	    all.checked = false;
    }
}

function CheckSelect(checked)
{
    if (checked==true)
        SelectAll();
    else
        DeSelectAll();
}

function SelectAll()
{
	for (var i=0; i<document.forms[0].elements.length;i++)
	{
		if ( document.forms[0].elements[i].disabled == false )
			document.forms[0].elements[i].checked = true ;		
	}
}

function DeSelectAll()
{
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		document.forms[0].elements[i].checked = false ;		
	}		
}
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) 
{
    var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
    var int_windowTop = (screen.height - a_int_windowHeight) / 2;
    var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
    var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties);
    if (parseInt(navigator.appVersion) >= 4) {
        obj_window.window.focus();
    }   
}
function ClientValidationDateTime(oSrc, args){
  var value = args.Value;
  var year;
  var month;
  var  day;
  var result=true;
  if( value.length > 10 ) result=false;
  else 
  {
      if(!isDate(value, "dd/MM/yyyy")) result = false;
  }

  args.IsValid = result;
}
function ClientValidationDDl(oSrc, args){
  var value = args.Value;
  if( value == "0" ) result=false;
  else
  result=true;
  args.IsValid = result;
}
function FormatNumber(str)
{
    var strTemp = GetNumber(str);
    if(strTemp.length <= 3)
        return strTemp;
    strResult = "";
    for(var i =0; i< strTemp.length; i++)
        strTemp = strTemp.replace(",", "");
    for(var i = strTemp.length; i>=0; i--)
    {
        if(strResult.length >0 && (strTemp.length - i -1) % 3 == 0)
            strResult = "," + strResult;
        strResult = strTemp.substring(i, i + 1) + strResult;
    }	
    return strResult
  
}
function GetNumber(str)
{
    for(var i = 0; i < str.length; i++)
    {	
        var temp = str.substring(i, i + 1);		
        if(!(temp == "," || temp == "." || (temp >= 0 && temp <=9)))
        {
            return str.substring(0, i);
        }
        if(temp == " ")
            return str.substring(0, i);
    }
    return str;
}